package com.sailfish.springbootdemo.service.db4;

import com.sailfish.springbootdemo.dao.db4.OperateDao;
import com.sailfish.springbootdemo.dao.db4.OperateLogDao;
import com.sailfish.springbootdemo.dao.db4.UserDao;
import com.sailfish.springbootdemo.pojo.db4.OperateLog;
import com.sailfish.springbootdemo.pojo.db4.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OperateLogServiceImpl implements OperateLogService{

    @Autowired
    private OperateLogDao operateLogDao;

    @Autowired
    private UserDao userDao;

    @Override
    public Boolean addOperateLog(OperateLog operate) {
        Integer operateId = operate.getOperatorId();
        User userInfoById = userDao.getUserInfoById(operateId);
        if (userInfoById != null) {
            operate.setNickNameCn(userInfoById.getNickNameCn());
        }
        return operateLogDao.addOperateLog(operate) > 0;
    }
}
